package com.fr.report.web.ui;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public abstract class WriteUnableRepeatEditor extends FieldEditor
{
  private boolean removeRepeat = true;

  public boolean isRemoveRepeat()
  {
    return this.removeRepeat;
  }

  public void setRemoveRepeat(boolean paramBoolean)
  {
    this.removeRepeat = paramBoolean;
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    if (isRemoveRepeat())
      localJSONObject.put("norepeat", true);
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isCharacters())
    {
      String str = paramXMLableReader.getTagName();
      if ("noRepeat".equals(str))
        setRemoveRepeat(Boolean.valueOf(paramXMLableReader.getContent()).booleanValue());
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (!(this.removeRepeat))
      paramXMLPrintWriter.startTAG("noRepeat").textNode(String.valueOf(this.removeRepeat)).end();
  }
}